<?php

namespace App\Validate;

use App\Validate\BaseValidate;

/**
 * 数字资源阅读书单管理
 */
class ResourceReadingListValidate extends BaseValidate
{
    //验证规则
    protected $rule = [
        'id' => 'bail|required|integer',
        'ids' => 'bail|required',
        'reading_id' => 'bail|required|integer',
        'img' => 'bail|required',
        'name' => 'bail|required',
        'intro' => 'bail|required',
        'type' => 'required|integer|in:1,2', //订单类型
        'is_play' => 'bail|required|in:1,2',
    ];
    //自定义验证信息
    protected $message = [
        'id.required' => 'ID不能为空',
        'id.integer' => 'ID格式不正确',
        'ids.required' => 'ID不能为空',
        'img.required' => '封面不能为空',
        'name.required' => '名称不能为空',
        'intro.required' => '内容不能为空',
        'type.required' => '类型不能为空',
        'type.in' => '类型规则不正确',
        'is_play.required' => '是否显示不能为空',
        'is_play.in' => '是否显示规则不正确',
        'reading_id.required' => 'ID不能为空',
        'reading_id.integer' => 'ID格式不正确',
    ];

    //自定义场景
    protected $scene = [
        'add' => ['img', 'name', 'intro'], //添加
        'change' => ['id', 'img', 'name', 'intro'], //修改
        'detail' => ['id'], //详情
        'del' => ['id'], //删除
        'cancel_and_release' => ['ids', 'is_play'], //切换显示方式

        'wx_get_reading_book_list' => ['reading_id'], //根据书单id获取书籍列表
        'wx_get_reading_detail' => ['reading_id'], //获取书单详情

    ];
}
